package com.myhome.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.myhome.dto.AdminBankDto;
import com.myhome.mappers.AdminBankMappers;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.myhome.mapper.AdminBankMapper;
import com.myhome.domain.AdminBank;
import com.myhome.service.AdminBankService;
import org.springframework.util.StringUtils;

/**
 * @Author QYiXin
 * @Date 2021 10 12 20 28
 **/
@Service
public class AdminBankServiceImpl extends ServiceImpl<AdminBankMapper, AdminBank> implements AdminBankService {

    @Override
    public Page<AdminBank> findByPage(Page<AdminBank> page, String bankCard) {
        return page(page, new LambdaQueryWrapper<AdminBank>()
                .like(!StringUtils.isEmpty(bankCard), AdminBank::getBankCard, bankCard));
    }

    @Override
    public List<AdminBankDto> getAllAdminBanksDto() {
        List<AdminBank> listAdminBank = this.list(new LambdaQueryWrapper<AdminBank>().eq(AdminBank::getStatus, (byte) 1));
        List<AdminBankDto> result = AdminBankMappers.INSTANCE.convert2Dto(listAdminBank);
        return result;
    }
}
